package day16;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by kunsb on 2016/11/3.
 */
public class Calandasfafh {

    public static void main(String[] args) {
        Calendar calendar = Calendar.getInstance();
        Date date = new Date(954354425541L);
        calendar.setTime(date);

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("now: " + dateFormat.format(calendar.getTime()));

        System.out.println("year: " + calendar.get(Calendar.YEAR));
        System.out.println("month: " + (calendar.get(Calendar.MONTH)+1));
        System.out.println("day: " + calendar.get(Calendar.DATE));
        calendar.set(Calendar.DATE, 28);
        System.out.println(dateFormat.format(calendar.getTime()));
        calendar.set(Calendar.MONTH, Calendar.SEPTEMBER);
        System.out.println(dateFormat.format(calendar.getTime()));

        calendar.add(Calendar.DATE, 7);
        System.out.println(dateFormat.format(calendar.getTime()));
        calendar.add(Calendar.DATE, -5);
        System.out.println(dateFormat.format(calendar.getTime()));
        calendar.add(Calendar.WEEK_OF_MONTH, 2);
        System.out.println(dateFormat.format(calendar.getTime()));

    }
}
